Skip to content

test: compare with isEqualTo instead of AssertJ containsExactly - #792

Merged
dfa1 merged 1 commit into
mainfrom
test/assertj-large-arrays
Nov 30, 2026
Merged

dfa1 merged 1 commit into
mainfrom
test/assertj-large-arrays

Conversation

@dfa1

@dfa1 dfa1 commented Nov 30, 2026

Copy link
Copy Markdown
Owner

AssertJ's containsExactly and containsExactlyElementsOf are O(n²) even when they pass (reported upstream as assertj/assertj#4518). On 3.27.7 with identical inputs, 200k long[] takes 4.4 s and a 200k List 5.2 s; isEqualTo takes 0 ms. JavaWritesRustReadsIntegrationTest spent about 10 of its 19 seconds in six such calls on 100k–200k arrays.

Every containsExactly(<array or list>) and containsExactlyElementsOf(<list>) in the tests is now isEqualTo (185 sites, 52 files). Varargs and literal containsExactly calls stay. Where a List was compared with an array, which containsExactly bridged through varargs, the expected side is Arrays.asList(...). The 13 such cases were in the writer tests, and the unit-test run found them.

🤖 Generated with Claude Code

@dfa1
dfa1 force-pushed the test/assertj-large-arrays branch from 2659ac7 to caec696 Compare November 30, 2026 06:16
AssertJ's containsExactly and containsExactlyElementsOf are O(n^2) even
when they pass (assertj/assertj#4518): JavaWritesRustReads spent about
7 of its 11 seconds in them on 100k-200k arrays (11.0 s -> 4.1 s,
sequential). containsExactly(<array or list>) and
containsExactlyElementsOf(<list>) in the tests are now isEqualTo, a
linear equals. Where containsExactly bridged a List and an array, the
expected side is Arrays.asList(...); a Set's order is checked as
List.copyOf(set). Kept as they were: varargs and literal calls, a single
element passed as varargs, and lists of byte[] (AssertJ compares those
by content, List.equals by reference).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dfa1
dfa1 force-pushed the test/assertj-large-arrays branch from caec696 to 0a56799 Compare November 30, 2026 06:30
@dfa1
dfa1 merged commit 5fc1423 into main Nov 30, 2026
6 checks passed
@dfa1
dfa1 deleted the test/assertj-large-arrays branch November 30, 2026 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant